

print("取绝对值：",abs(-2))
print("获取商和余数",divmod(5,2))
print("2的3次幂",pow(2,3))
print("四舍五入", round(3.1415926))
print("四舍五入", round(3.1415926,4))
print("求和",sum([1,2,4,56,5]))
print("最大",max([1,2,4,56,5]))
print("最小",min([1,2,4,56,5]))
print("100转换为二进制",bin(100))

x=5
print("将一行字符串看做是python代码执行",eval("x*2+1"))

# my_input=input("请输入你要执行的数学公式：")
# print(my_input,"=",eval(my_input))

# my_input2=input("请输入你要执行语句：")
# exec(my_input2)

# 判断是否为奇数
def is_odd(num):
    return num%2==1

is_odd2 =  lambda num : num%2==1

print(list(map(is_odd,range(1,5))))

# for n in range(1,5):
#     print(is_odd(n))

print(list(map(abs,[-2,-3,1,5,-10])))

def is_greater(num1,num2):
    return num1>num2

print(list(map(is_greater,[2,4,6,8],[5,1,4,10])))




print(list(filter(is_odd,[1,2,3,4,5,6,11])))


print(list(filter(lambda num : num%2==0,[1,2,3,4,5,8])))

print(list(map(lambda x,y : x<y,[2,4,6,8],[5,1,4,10])))


# line=int(input("请输入要打印的三角形的行数："))
# for line in list(map(lambda count : ("*"*count).center(50),range(1,2*(line+1)-1,2))):
#     print(line)

def harmonic( count):
    total = 0
    for num in range(1,count+1):
        total +=1/num
    return total

n=int(input("请输入多少阶的调和数："))
print(sum(list(map(lambda num :1/num,range(1,n+1)))))

print(sum([1/num for num in range(1,n+1)]))